<!DOCTYPE html>
<html>

{include file='public/header'}

<body>
    <div class="x-nav">
        <span class="layui-breadcrumb">
            <a href="javascript:void(0)">首页</a>
            <a href="javascript:void(0)">版权合作</a>
            <a><cite>版权方账号管理</cite></a>
        </span>
        <a class="layui-btn layui-btn-small" id="reload" title="刷新">
            <i class="layui-icon" style="line-height:30px"><i class="iconfont">&#xe6aa;</i></i>
        </a>
    </div>
    <div class="x-body">
        <div class="layui-row">
            <form class="layui-form">
                <div class="layui-inline">
                    <label class="layui-form-label w-auto">版权方名称：</label>
                    <div class="layui-input-inline">
                        <input type="text" name="name" placeholder="请输入版权方名称" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <button class="layui-btn" style="margin-left: 10px;" lay-submit lay-filter="searchList">搜索</button>
                <button type="reset" id="resetList" class="layui-btn layui-btn-primary">重置</button>
            </form>
        </div>
        <table id="partners" lay-filter="partners"></table>
    </div>
    <script type="text/html" id="toolbarDemo">
        <div class="layui-btn-container">
            <button class="layui-btn layui-btn-sm" lay-event="add">添加版权方</button>
        </div>
    </script>
    <script type="text/html" id="tbBar">
        <a class="layui-btn layui-btn-xs" lay-event="look">查看作品</a>
        <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
        <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
    </script>
    <script>
        let params = {
            elem: '#partners'
            , toolbar: '#toolbarDemo'
            , url: '{:url("admin/partners/list")}' //数据接口
            , id: 'partners'
            ,page:true
            , cols: [[ //表头
                { field: 'id', title: 'ID', width: 60, sort: true, align:'center'}
                , { field: 'name', title: '名称', align:'center', width: 220}
                , { field: 'abbreviation', align:'center', title: '简称', align:'center', width: 80}
                , { field: 'type', align:'center', width: 100, title: '合作类型', templet: function (d) {
                        return d.type == 1 ? '输入方' : '输出方'
                    } 
                }
                , { field: 'start_time', align:'center', width: 110, title: '开始时间', templet: function (d) {
                        return d.start_time == 0 ? '' : dayjsFormat(d.start_time,false)
                    } 
                }
                , { field: 'end_time', align:'center', width: 110, title: '结束时间', templet: function (d) {
                        return d.end_time == 0 ? '' : dayjsFormat(d.end_time,false)
                    } 
                }
                , { field: 'payment_method', align:'center', width: 125, title: '收款方式', templet: function (d) {
                        return d.payment_method == 1 ? '银行卡(对公)' : d.payment_method == 2 ? '银行卡(对私)' : ''
                    }
                }
                , { field: 'payee', align:'center', title: '收款人', width: 180, align:'center'}
                , { field: 'collection_account', align:'center', title: '收款账号', width: 220, align:'center'}
                , { field: 'bank_name', align:'center', title: '开户行', align:'center', width: 240}
                , { toolbar: '#tbBar', align:'center', title: '操作',width:220}
            ]]
        }
        tableList(params)

        layui.use('table', function () {
            var table = layui.table;
            table.on('toolbar(partners)', function (obj) {
                var event = obj.event;
                if (event === 'add') {
                    x_admin_show('添加版权方', './info.html', 650, 700);
                }
            });
            table.on('tool(partners)', function (obj) {
                var event = obj.event;
                if (event === 'del') {
                    DeleteAjax('/admin/partners/delete',{ id: obj.data.id },'partners')
                } else if (event === 'edit') {
                    x_admin_show('编辑版权方', `./info.html?id=${obj.data.id}`, 650, 700);
                } else if (event === 'look') {
                    x_admin_show('查看作品', `./see.html?id=${obj.data.id}`, 1400, 573,null);
                }
            });
        });


    </script>
</body>

</html>